<!--
 * @Author: 刘十三
 * @Date: 2023-12-28 11:18:14
 * @LastEditors: 刘十三
 * @LastEditTime: 2024-03-15 09:36:11
 * @FilePath: \NM-dev-1.3.1\dev\pages\query\specialArea\components\checkRecordList.vue
 * @Description: 监管对象查询-特殊区域查询-检查记录列表 （改造，2024-03-08）节日快乐
-->

<template>
  <view>
    <me-table :i="0" :index="0" :load-data="loadData" :top="0" :init-load="false" ref="mescrollItem0" :height="height">
      <view slot-scope="d" class="list-item-root list-lay">
        <view class="lt-root">
          <view class="lt-row">
            <text class="lt-left-label">
              检查人：
            </text>
            <text class="lt-right-value">
              {{ d.data.checkPersonName }}
            </text>
          </view>
          <view class="lt-row">
            <text class="lt-left-label">
              是否涉案：
            </text>
            <text class="lt-right-value">
              {{ d.data.isCase == 1 ? "是" : "否" }}
            </text>
          </view>
          <view class="lt-row">
            <text class="lt-left-label">
              检查类型：
            </text>
            <text class="lt-right-value">
              {{ d.data.planTypeName }}
            </text>
          </view>
          <view class="lt-row">
            <text class="lt-left-label">
              检查日期：
            </text>
            <text class="lt-right-value">
              {{ d.data.checkTime }}
            </text>
          </view>
        </view>
      </view>
    </me-table>
    <u-popup v-model="searchVisable" width="80%" mode="right">
      <view class="cearch_title">
        查询条件
      </view>
      <u-form :model="serachForm" label-position="top" label-width="auto" style="padding: 80rpx 32rpx 0 32rpx" ref="uForm">
        <template v-if="searchVisable">
          <u-form-item label="只显示违规" prop="showViolation">
            <u-radio-group v-model="serachForm.showViolation">
              <u-radio :name="1">违规</u-radio>
              <u-radio :name="0">不违规</u-radio>
            </u-radio-group>
          </u-form-item>
          <u-form-item label="检查开始日期:" prop="startDate">
            <z-date placeholder="请选择" v-model="serachForm.startDate" />
          </u-form-item>
          <u-form-item label="检查结束日期:" prop="endDate">
            <z-date placeholder="请选择" v-model="serachForm.endDate" />
          </u-form-item>
        </template>
      </u-form>
      <view class="submit-btns btn-other-cls">
        <u-button plain class="del" type="primary" @tap="handleRest">
          重置
        </u-button>
        <u-button class="mit" type="primary" @tap="selectChange">
          确定
        </u-button>
      </view>
    </u-popup>
  </view>
</template>

<script>
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import meTable from "@/components/me-table.vue";
import certificateService from "@/service/certificate/certificate.service.js";
import { ZDate } from "@/components";

export default {
  name: "caseRecordList",
  components: {
    meTable,
    ZDate,
  },
  mixins: [MescrollMoreMixin],
  props: {
    height: {
      // 高度
      type: String,
      default: "0px",
    },
    areaUuid: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      serachForm: {
        startDate: "",
        showViolation: 0,
        endDate: "",
      },
      searchVisable: false,
    };
  },
  methods: {
    handleRest() {
      this.serachForm = {
        startDate: "",
        showViolation: 0,
        endDate: "",
      };
    },
    selectChange() {
      if (this.serachForm.startDate && this.serachForm.endDate) {
        if (new Date(this.serachForm.startDate) > new Date(this.serachForm.endDate)) {
          return this.$u.toast("检查开始日期不能大于检查结束日期");
        }
      }
      this.searchVisable = false;
      this.handleReferList();
    },
    handleReferList() {
      let mescroll = this.getMescroll(0);
      mescroll && mescroll.triggerDownScroll();
    },
    loadData(paper) {
      let param = {
        page: paper.num,
        limit: paper.size,
        areaUuid: this.areaUuid,
        ...this.serachForm,
      };
      return new Promise((resolve, reject) => {
        certificateService
          .getAreaCheckDetail(param)
          .then((res) => {
            if (res.success && res.code == 0) {
              resolve({
                count: res.count,
                data: [...res.data],
              });
            } else {
              resolve({
                count: 0,
                data: [],
              });
            }
          })
          .catch((e) => {
            resolve({
              count: 0,
              data: [],
            });
          });
      });
    },
  },
};
</script>

<style scoped lang="scss">
@import "../list_item.scss";
.list-lay {
  background-color: #fff;
  padding: 2px 10px;
  margin-bottom: 10px;
  border-radius: 10px;
}
.cearch_title {
  background-color: #f3f4f5;
  width: 100%;
  height: 82rpx;
  font-size: 32rpx;
  font-weight: 600;
  padding: 22rpx 0 21rpx 32rpx;
  z-index: 999;
  position: fixed;
}
</style>
